package com.haier.cloudremote.common;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

public class LogOperation {

	/**
     * 以字节为单位读取文件，常用于读二进制文件，如图片、声音、影像等文件。
     */
    public static StringBuffer readFileByBytes(String fileName) {
    	StringBuffer sBuffer = null;
        try {
			InputStreamReader sr = new InputStreamReader
					(new FileInputStream(fileName), "GBK");
			BufferedReader reader = new BufferedReader(sr);
			sBuffer = new StringBuffer();
			String temp;
			while ((temp=reader.readLine())!=null) {
				sBuffer.append(temp);
                System.out.println(temp);
            }
            sr.close();
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			if(e1!=null){
				SLog.e("ssc", "LogOperation--------33------e===="+e1.getMessage());
			}
			
		} catch (FileNotFoundException e2) {
			// TODO Auto-generated catch block
			if(e2!=null){
				SLog.e("ssc", "LogOperation--------39------e===="+e2.getMessage());
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			if(e!=null){
				SLog.e("ssc", "LogOperation--------44------e===="+e.getMessage());
			}
		} 
        return sBuffer;
    }
}
